<?php
class Upload_artwork extends Controller
{
    function __construct()
    {
        parent::__construct();
        
        $this->load->library('session' , 'form_validation');
        
		 if($this->session->userdata('admin') == '')
		 {    
		     redirect('admin');
		 }
         
        $this->load->helper(array('form','tiap_helper','html'));
        
        $this->load->model('upload_artwork_model');
    }
    function index(){
	
		$data = array();
    	
		 $page = (int)$this->uri->segment(4);
		
		$page = ($page == '')?0:$page;
		
	   	$per_page = 15;
    	$data['total_artworks'] = $this->upload_artwork_model->total_artwork_uploads();
		// pagination start
		$this->load->library('pagination');
		$config['base_url'] = site_url('admin/upload_artwork/index/');
		$config['total_rows'] = $data['total_artworks'];
		$config['per_page'] = $per_page;
	
		$config['uri_segment'] = 4;

		$this->pagination->initialize($config); 

		$data['pagination'] =  $this->pagination->create_links();
		//pagination end
    	$data['order_by'] = $order_by;
    	
    	
    	$data['artworks_list'] = $this->upload_artwork_model->get_artworks($per_page,$page);
        $data['page']=$page;
    	
		$this->load->view(TEMPLATE_NAME.'/admin/upload_artwork/list',$data);
		
		}
		
		function detail()
        {
			$data = array();
    	    $artwork_id = (int)$this->uri->segment(4);
            $page = (int)$this->uri->segment(5);
            $data['page']=$page;	
			$data['artworks_detail']=$this->upload_artwork_model->get_artworks_detail($artwork_id );
            //$a=$this->upload_artwork_model->get_artwork_uploads_detail($artwork_id );
            $data['uploads_detail']=$this->upload_artwork_model->get_artwork_uploads_detail($artwork_id );
           
			$this->load->view(TEMPLATE_NAME.'/admin/upload_artwork/detail',$data);
			}
			
		function delete()
        {
            $page= (int)$this->uri->segment(5);
            $data['page']=$page;
            $artwork_id= (int)$this->uri->segment(4);
            $check= $this->upload_artwork_model->delete_artworks($artwork_id);
            redirect('admin/upload_artwork');
		}
}
?>